﻿using System;
using System.Collections.Generic;

namespace Gqq.Csharpindepth.Chapter23
{
    public class Test23Class
    {
        public static void Test()
        {
            var a = new A();
            Pair<int, A> p = new Pair<int, A>(3, a);
            Pair<int, A> q = new Pair<int, A>(3, a);
            Console.WriteLine(p.Equals(q));

            //凡是实现了IEnumerable的接口的类，都可以遍历。
            CountEnumerable ce = new CountEnumerable();
            foreach (var number in ce)
            {
                Console.WriteLine(number);
            }

            var strs = CountEnumerable.InputTest(0);
//            foreach (var str in strs)
//            {
//                Console.WriteLine(str);
//            }
            //通过迭代器来访问元素。
            IEnumerator<string> str = strs.GetEnumerator();
            str.MoveNext();
            Console.WriteLine(str.Current);
            str.MoveNext();
            Console.WriteLine(str.Current);
        }

        class A
        {
             
        }
    }

}
